﻿using CrawlerFramework.DataConverter;
using RakutenProxy.Model.NopCommerce;
using RakutenProxy.Model.Rakuten;
using System;

namespace RakutenProxy.DataConverter
{
    public class RakutenDataConverterFactory
    {
        public static IDataConverter GetDataConverter(Type sourceType)
        {
            var sourceDbContext = new RakutenDbContext();
            var targetDbContext = new NopCommerceEntities();

            IDataConverter result = null;

            if (sourceType == typeof(Model.Rakuten.Product))
                result = new RakNopProductConverter(sourceDbContext, targetDbContext);
            if (sourceType == typeof(Model.Rakuten.Manufacturer))
                result = new RakNopManufacturerConverter(sourceDbContext, targetDbContext);
            if (sourceType == typeof(Model.Rakuten.ProductAttribute))
                result = new RakNopProductAttributeConverter(sourceDbContext, targetDbContext);
            if (sourceType == typeof(Model.Rakuten.ProductAttributeCombination))
                result = new RakNopProductAttributeCombinationConverter(sourceDbContext, targetDbContext);
            if (sourceType == typeof(Model.Rakuten.ProductAttributeValue))
                result = new RakNopProductAttributeValueConverter(sourceDbContext, targetDbContext);
            if (sourceType == typeof(Model.Rakuten.Category))
                result = new RakNopCategoryConverter(sourceDbContext, targetDbContext);
            if (sourceType == typeof(Model.Rakuten.Product_ProductAttribute_Mapping))
                result = new RakNopProductProductAttributeMappingConverter(sourceDbContext, targetDbContext);

            return result;
        }
    }
}